// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_ability/custom_ui.dart';

class YJBackButton extends StatelessWidget {
  const YJBackButton({super.key, this.color, this.onPressed});

  final Color? color;

  final VoidCallback? onPressed;

  @override
  Widget build(BuildContext context) {
    assert(debugCheckHasMaterialLocalizations(context));
    return Container(
      child: IconButton(
        icon: Icon(
          Icons.arrow_back_ios,
          size: YJSize.SP_16,
        ),
        color: color,
        // tooltip: MaterialLocalizations.of(context).backButtonTooltip,
        onPressed: () {
          if (onPressed != null) {
            onPressed!();
          } else {
            Navigator.maybePop(context);
          }
        },
      ),
    );
  }
}

class YJNoneButton extends StatelessWidget {
  const YJNoneButton({super.key, this.children});

  final Widget? children;

  @override
  Widget build(BuildContext context) {
    assert(debugCheckHasMaterialLocalizations(context));
    return Container(
      child: Container(
        child: IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
            size: YJSize.SP_16,
          ),
          color: Colors.blue,
          // tooltip: MaterialLocalizations.of(context).backButtonTooltip,
          onPressed: () {
            Navigator.maybePop(context);
          },
        ),
      ),
    );
  }
}

class YJCloseButton extends StatelessWidget {
  const YJCloseButton({super.key, this.color, this.onPressed});

  final Color? color;
  final VoidCallback? onPressed;

  @override
  Widget build(BuildContext context) {
    assert(debugCheckHasMaterialLocalizations(context));
    return IconButton(
      icon: Icon(
        Icons.close,
        size: YJSize.SP_16,
      ),
      color: color,
      tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
      onPressed: () {
        if (onPressed != null) {
          onPressed!();
        } else {
          Navigator.maybePop(context);
        }
      },
    );
  }
}
